//
//  TopUpResultViewController.m
//  PigMarket
//
//  Created by mac on 2019/5/29.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "TopUpResultViewController.h"

@interface TopUpResultViewController ()
/**
 完成Btn
 */
@property (nonatomic , strong) UIButton *completeBtn;
/**
 bgVIew
 */
@property (nonatomic , strong) UIView *bgView;
/**
 充值结果
 */
@property (nonatomic , strong) UILabel *resultLab;
/**
 充值金额
 */
@property (nonatomic , strong) UILabel *moneyLab;
/**
 付款方式
 */
@property (nonatomic , strong) UILabel *payTypeLabTitle;
/**
 付款方式  微信  支付宝
 */
@property (nonatomic , strong) UILabel *payTypeLab;
@end

@implementation TopUpResultViewController

#pragma mark - view life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpView];
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

-(void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

#pragma mark - init method
- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}
- (void)initView {
    [self.view addSubview:self.bgView];
    [self.bgView addSubview:self.completeBtn];
    [self.bgView addSubview:self.resultLab];
    [self.bgView addSubview:self.moneyLab];
    [self.bgView addSubview:self.payTypeLabTitle];
    [self.bgView addSubview:self.payTypeLab];
}

- (void) initLayout {
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
    }];
    [self.completeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(TopBarHeight);
        make.height.mas_equalTo(25);
    }];
    [self.resultLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.completeBtn.mas_bottom).offset(14 * [JTool getScreenWidthScale]);
        make.centerX.mas_equalTo(self.bgView.mas_centerX);
        make.height.mas_equalTo(22);
    }];
    [self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.resultLab.mas_bottom);
        make.height.mas_equalTo(45 * [JTool getScreenWidthScale]);
        make.centerX.mas_equalTo(self.bgView.mas_centerX);
    }];
    [self.payTypeLabTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.moneyLab.mas_bottom).offset(5 * [JTool getScreenWidthScale]);
        make.height.mas_equalTo(20);
    }];
    [self.payTypeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.payTypeLabTitle.mas_centerY);
        make.height.mas_equalTo(22);
        make.bottom.mas_equalTo(-10);
    }];
    
}

- (void) initAction {
    [self.completeBtn addTarget:self action:@selector(completeBtnClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)initData {
    self.moneyLab.text = [NSString stringWithFormat:@"￥%@",self.topupMoney];
    self.payTypeLab.text = self.payType;
}

#pragma mark - delegate

#pragma mark - target action
- (void)completeBtnClick {
//    [self.rtNavigationController removeViewControllerWithName:@"TopUpViewController"];
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - private method

#pragma mark - getter and setter
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UIButton *)completeBtn {
    if (!_completeBtn) {
        _completeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_completeBtn setTitle:@"完成" forState:UIControlStateNormal];
        [_completeBtn setTitleColor:[UIColor primaryColor] forState:UIControlStateNormal];
        _completeBtn.titleLabel.font = [UIFont systemFontOfSize:18];
    }
    return _completeBtn;
}
- (UILabel *)resultLab {
    if (!_resultLab) {
        _resultLab = [[UILabel alloc] init];
        _resultLab.textColor = [UIColor textBlackColor];
        _resultLab.font = [UIFont systemFontOfSize:16];
        _resultLab.text = @"充值成功";
    }
    return _resultLab;
}
- (UILabel *)moneyLab {
    if (!_moneyLab) {
        _moneyLab = [[UILabel alloc] init];
        _moneyLab.textColor = [UIColor textBlackColor];
        _moneyLab.font = [UIFont systemFontOfSize:32];
    }
    return _moneyLab;
}
- (UILabel *)payTypeLabTitle {
    if (!_payTypeLabTitle) {
        _payTypeLabTitle = [[UILabel alloc] init];
        _payTypeLabTitle.textColor = [UIColor colorWithHexString:@"#AAAAAA"];
        _payTypeLabTitle.font = [UIFont systemFontOfSize:14];
        _payTypeLabTitle.text = @"付款方式";
    }
    return _payTypeLabTitle;
}
- (UILabel *)payTypeLab {
    if (!_payTypeLab) {
        _payTypeLab = [[UILabel alloc] init];
        _payTypeLab.textColor = [UIColor colorWithHexString:@"#3B3B3B"];
        _payTypeLab.font = [UIFont systemFontOfSize:14];
        _payTypeLab.textAlignment = NSTextAlignmentRight;
    }
    return _payTypeLab;
}
@end
